home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / Bookmark.subproj / eTBookmarkEnd.m < prev    next >
Encoding:
Text File  |  1994-11-04  |  2.7 KB  |  110 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //    FILENAME:    eTBookmarkEnd.m
  3. //    SUMMARY:    Implementation of the "stupid" end-of-region tag
  4. //    SUPERCLASS:    Object
  5. //    INTERFACE:    None
  6. //    PROTOCOLS:    <Annotation>
  7. //    AUTHOR:        Rohit Khare
  8. //    COPYRIGHT:    (c) 1994 California Institure of Technology, eText Project
  9. ///////////////////////////////////////////////////////////////////////////////
  10. //  IMPLEMENTATION COMMENTS
  11. //        Does as close to nothing as possible.
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //    HISTORY
  14. //    05/08/94:    Created. First actual implementation.
  15. ///////////////////////////////////////////////////////////////////////////////
  16.  
  17. #import "eTBookmarkEnd.h"
  18.  
  19. @implementation eTBookmarkEnd
  20. //    id         etBookmark;
  21. //    long    anchorID;
  22.  
  23. - init {return [self init:nil ID:0];}
  24.  
  25. - init:theBookmark ID:(long)theID
  26. {
  27.     [super init];
  28.     etBookmark = theBookmark;
  29.     anchorID = theID;
  30.     theIcon = [NXImage findImageNamed:".bmEnd"];
  31.     highlighted = NO;
  32.     return self;
  33. }
  34.  
  35. - beginDidFree
  36. {
  37.     etBookmark = nil;
  38.     return self;
  39. }
  40.  
  41. - free
  42. {
  43.     if (etBookmark) etBookmark = [etBookmark endDidFree:self];
  44.     return self = [super free];
  45. }
  46.  
  47. - click:sender {if (etBookmark) [etBookmark click:sender]; return self;}
  48. - doubleClick:sender {if (etBookmark) [etBookmark doubleClick:sender]; return self;}
  49.  
  50. /////////////////////////
  51. - initFromPboard:thePboard inDoc:theDoc linked:(BOOL) linked
  52. {
  53.     NXLogError("initFromPboard called for bmEnd; should not have happened");
  54.     return [self init];
  55. }
  56. - calcCellSize:(NXSize *)theSize 
  57.     {[theIcon getSize:theSize]; return self;}
  58. - drawSelf:(const NXRect *)cellFrame inView:view        // MARGINALIA HERE!
  59. {
  60.     NXPoint    point;
  61.     
  62.     PSgsave();
  63.     PSsetgray([view backgroundGray]);
  64.     NXRectFill(cellFrame);
  65.     point = cellFrame->origin;
  66.     point.y += cellFrame->size.height;
  67.     [theIcon composite:NX_SOVER toPoint:&point];
  68.     PSgrestore();
  69.     return self;
  70. }
  71. - highlight:(const NXRect *)cellFrame inView:view lit:(BOOL)flag
  72. {
  73.     if (highlighted != flag) {
  74.         highlighted = flag;
  75.       /* toggle highlighting */
  76.         NXHighlightRect(cellFrame);
  77.     }
  78.     return self;
  79. }
  80. - (BOOL)    trackMouse:(NXEvent *)theEvent
  81.             inRect:(const NXRect *)rect
  82.             ofView:view
  83. {
  84.      // TO fix this, check out Concepts chapter 7, prog dynam.
  85.     if (!etBookmark) {    
  86.         if (theEvent->data.mouse.click == 2)
  87.             [self doubleClick:self];
  88.         else if (theEvent->data.mouse.click == 1)
  89.             [self click:self];
  90.     } else {
  91.         [etBookmark trackMouse:theEvent inRect:rect ofView:view];
  92.     }
  93.     return YES;
  94. }
  95.  
  96. - writeRichText:(NXStream *)stream forView:view
  97. {
  98.     NXPrintf(stream, "%x ", anchorID);
  99.     return self;
  100. }
  101. - readRichText:(NXStream *)stream forView:view 
  102. {
  103.     NXScanf(stream, "%x ", &anchorID);
  104.     etBookmark = [[eTBookmarkBinder new] bookmarkForID:anchorID];
  105.     [etBookmark setEnd:self]; 
  106.     return self;
  107. }
  108.  
  109. @end
  110.